package com.bot.nft.module.dc.controller;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bot.common.pojo.CommonResult;
import com.bot.nft.module.dc.domain.vo.DcBillLogVo;
import com.bot.nft.module.dc.service.IDcBillLogService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author RenXiaoZheng
 * @since 2024-01-24
 */
@RestController
@RequestMapping("/bill")
public class DcBillLogController {


    @Resource
    IDcBillLogService dcBillService;

    //分页查询交易账单信息
    @RequestMapping("/{pageNo}/{pageSize}/queryDcBill.do")
    public CommonResult<Page> selectDcBill(@RequestBody Integer Status, @PathVariable("pageNo") Integer pageNo, @PathVariable("pageSize") Integer pageSize) {
        Page<DcBillLogVo> dcBillLogVoPageInfo = dcBillService.queryDcBillLog(Status, pageNo, pageSize);
        CommonResult<Page> commonResult = new CommonResult<>();
        if (ObjectUtil.isNotNull(dcBillLogVoPageInfo)) {
            commonResult.setMsg("操作成功");
            commonResult.setCode(200);
            commonResult.setData(dcBillLogVoPageInfo);
        } else {
            commonResult.setMsg("操作失败");
            commonResult.setCode(500);
        }
        return commonResult;
    }

    //查看交易账单信息
    @RequestMapping("/getDcBill.do")
    public CommonResult<DcBillLogVo> getDcBill(@RequestParam("id") String id) {
        //调用接口
        DcBillLogVo dcBillLog = dcBillService.getDcBillLog(id);
        CommonResult<DcBillLogVo> commonResult = new CommonResult<>();
        if (ObjectUtil.isNotNull(dcBillLog)) {
            commonResult.setMsg("操作成功");
            commonResult.setCode(200);
            commonResult.setData(dcBillLog);
        } else {
            commonResult.setMsg("操作失败");
            commonResult.setCode(500);
        }
        return commonResult;
    }


}
